package cn.itcast.javabase;

/**
 * @title: A03
 * @Author Zhou
 * @Date: 2022/1/18 14:36
 * @Version 1.0
 */
public class A03 {
    public static void main(String[] args) {
        Book book1 = new Book("海底两万里", 200.4);
        double price = book1.getPrice();
        System.out.println(price);
        book1.updatePrice();
        System.out.println("price = " + book1.price);

    }
}

class Book {
    String name;
    double price;

    public Book(String name, double price) {
        this.price = price;
        this.name = name;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public double getPrice() {
        return price;
    }

    public void updatePrice() {
        if (price > 150) {
            price = 150;
        } else if (price > 100) {
            price = 100;
        }
        System.out.println("price = " + price);
    }
}
